import {
  Controller,
  Post,
  UploadedFile,
  UseGuards,
  UseInterceptors,
} from '@nestjs/common';
import { UploadService } from './upload.service';
import { FileInterceptor } from '@nestjs/platform-express';
import { ThrottlerProxyGuard } from '@/authGuard/throttler.guard';

@Controller()
export class UploadController {
  constructor(private readonly uploadService: UploadService) {}
  @Post('upload')
  @UseInterceptors(FileInterceptor('file'))
  uploadAvator(@UploadedFile() file) {
    return this.uploadService.uploadAvator(file);
  }

  @Post('uploadFile')
  @UseInterceptors(FileInterceptor('file'))
  uploadFile(@UploadedFile() file) {
    return this.uploadService.uploadFile(file);
  }

  @Post('uploadTemp')
  @UseInterceptors(FileInterceptor('file'))
  uploadTemp(@UploadedFile() file) {
    return this.uploadService.compress(file);
  }

  @UseGuards(ThrottlerProxyGuard)
  @Post('compress')
  @UseInterceptors(FileInterceptor('file'))
  compress(@UploadedFile() file) {
    return this.uploadService.compress(file);
  }
}
